<?php
/**
 * This file is part of won-uploader.
 *
 * Author: Daniel K.
 *
 * won-uploader is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * won-uploader is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with won-uploader. If not, see <http://www.gnu.org/licenses/>.
 */
   
	if( !defined("won-uploader")) die("");    // Silence is golden
   
    $_nano->executeQuery("
    CREATE TABLE `users` ( 
    `userid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `username` VARCHAR(16) UNIQUE NOT NULL,
    `password` VARCHAR(128) NOT NULL,
    `email` VARCHAR(128),
    `disabled` BOOLEAN DEFAULT FALSE,
    `adm` BOOLEAN DEFAULT FALSE,
    `language` VARCHAR(3) NOT NULL DEFAULT 'en'
    )
    ");
    
    $_nano->executeQuery("
    CREATE TABLE `uploads` (
    `uploadid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `filename` VARCHAR(256) NOT NULL,
    `size` INT,
    `mime` VARCHAR(255) NOT NULL DEFAULT 'application/octet-stream',
    `uploaded` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `ip` VARCHAR(15),
    `user` INT NOT NULL
    )
    ");
    
    $_nano->executeQuery("
    CREATE TABLE `messages` (
    `messageid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `user` INT NOT NULL,
    `title` VARCHAR(200) NOT NULL,
    `file` INT NOT NULL,
    `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `type` INT NOT NULL,
    `version` VARCHAR(16) NOT NULL,
    `md5` VARCHAR(128) DEFAULT NULL,
    `changelog` LONGTEXT,
    `features` LONgTEXT,
    `flash` LONGTEXT
    )
    ");
    
    $_nano->executeQuery("
    CREATE TABLE `emails` (
    `emailid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `email` VARCHAR(128) NOT NULL
    )
    ");
    
    $_nano->executeQuery("
   	CREATE TABLE `assignments` (
    `assignid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `file` INT NOT NULL,
    `foreign` INT NOT NULL
    )
	");
?> 